<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@page import="com.yellowpage.white.common.PageRender"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<%
	PageRender pr = (PageRender) request.getAttribute("pageRender");
	String themePage = getServletContext().getInitParameter("white-theme");	
%>

<table width='0' border='0' cellspacing='0' cellpadding='0'>
	<tr valign=middle>
		<td width='61'>
			&nbsp;
		</td>
		<td width='47'>
		</td>
		<td width='267' class='copy_1'>
			每页
			<input name='perPageNum' type='text' value='<%=pr.getPerPageNum()%>'
				size='2' />
			条 &nbsp;&nbsp; 共
			<%=pr.getTotals()%>条&nbsp;&nbsp;第&nbsp;<%=pr.getPage()%>/<%=pr.getAllpage()%>
			&nbsp;页
		</td>		
		<%
			if (pr.getPage() > 1) {
		%>
		<td width='25'>
			<a href='javascript:toPageQuery(1)'> <img
					src='${ctx}/white/theme/<%=themePage%>/images/pageRender/g2.jpg' width='21' height='16' border='0' />
			</a>
		</td>
		<td width='45'>
			<a href='javascript:toPageQuery(<%=pr.getPage() - 1%>)'> <img
					src='${ctx}/white/theme/<%=themePage%>/images/pageRender/g3.jpg' width='41' height='16' border='0' />
			</a>
		</td>
		<%
			} else {
		%>
		<td width='25'>
			&nbsp;
		</td>
		<td width='25'>
			&nbsp;
		</td>
		<%
			}
		%>

		<%
			if (pr.getPage() < pr.getAllpage()) {
		%>
		<td width='45'>
			<a href='javascript:toPageQuery(<%=pr.getPage() + 1%>)'> <img
					src='${ctx}/white/theme/<%=themePage%>/images/pageRender/g4.jpg' width='41' height='16' border='0' />
			</a>
		</td>
		<td width='25'>
			<a href='javascript:toPageQuery(<%=pr.getAllpage()%>)'> <img
					src='${ctx}/white/theme/<%=themePage%>/images/pageRender/g5.jpg' width='21' height='16' border='0' />
			</a>
		</td>
		<%
			} else {
		%>
		<td width='25'>
			&nbsp;
		</td>
		<td width='25'>
			&nbsp;
		</td>
		<%
			}
		%>

		<td width='133' class='copy_1'>
			&nbsp;
		</td>
		<td width='110'>
			<span class='copy_1'>
			    转到第 <input name='page' type='text'
					      value='<%=pr.getPage()%>' size='2' />页
			</span>
		</td>

		<td width='24'>
			<a href='javascript:toSpecifiedPageQuery(<%=pr.getAllpage()%>)'>
				<img src='${ctx}/white/theme/<%=themePage%>/images/pageRender/g6.jpg' width='24' height='22'
					border='0' /> </a>
		</td>
		<td width='67'>
			&nbsp;
		</td>
	</tr>
</table>


&nbsp;&nbsp;

<s:hidden name="orderBy" />
<s:hidden name="orderDir" />
<s:hidden name="byPage" />

<script language="javascript">
	var curForm = document.getElementById("searchForm");
	
	
	if (curForm == null) {
	
		curForm = document.forms[0];
		
	}

	function toPageQuery(page) {    

		curForm.page.value = page;

		curForm.method = "post";
		curForm.target = "_self";
		curForm.byPage.value = "true";
		curForm.submit();
	}

	function toSpecifiedPageQuery(allPage) {	    
		var toPage = document.getElementsByName('page')[0].value;
		if (toPage > allPage) {
			document.getElementsByName('page')[0].value = allPage;
		}
		if (toPage < 1) {
			document.getElementsByName('page')[0].value = 1;
		}
		
		var perpagenum = document.getElementsByName('perPageNum')[0].value;
		if (perpagenum < 1) {
			document.getElementsByName('perPageNum')[0].value = 20;
		}
		
		var reg = /^[0-9]*[1-9][0-9]*$/;
		if (!toPage.match(reg)) {
			alert("转入页数只能输入正整数，请重新输入");
			return;
		}
		if (!perpagenum.match(reg)) {
			alert("每页条数只能输入正整数，请重新输入");
			return;
		}
		
		curForm.method = "post";
		curForm.target = "_self";
		curForm.byPage.value = "true";
		curForm.submit();
	}

	function orderBy1(colName) {
		curForm.orderBy.value = colName;
		if (curForm.orderDir.value == '' || curForm.orderDir.value == 'asc') {
			curForm.orderDir.value = 'desc';
		} else {
			curForm.orderDir.value = 'asc';
		}
		curForm.submit();
	}
</script>
